package com.example.vueblog.common.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * redis工具类
 *
 * @author yushunshun
 * @date 2022/7/21 0:55
 */
@Component
public class RedisUtils {

    @Autowired
    private StringRedisTemplate redisTemplate;

    public void set(String ket, String value) {
        redisTemplate.opsForValue().set(ket, value);
    }
    public void set(String ket, String value,long time) {
        redisTemplate.opsForValue().set(ket, value,time, TimeUnit.MINUTES);
    }

    public String get(String key){
        return redisTemplate.opsForValue().get(key);
    }
}
